local extension = Package:new("ikun")
extension.extensionName = "ikun"

Fk:loadTranslationTable{
  ["ikun"] = "ikun包",
}


-- 蔡徐坤来啦
-- 黑红：锁定技。当你受到伤害时，增加一点体力上限
local ik__heihong = fk.CreateTriggerSkill {
  name = "ik__heihong",
  mute = true,
  frequency = Skill.Compulsory,
  events = { fk.DamageInflicted },

  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if event == fk.DamageInflicted then
      player:broadcastSkillInvoke(self.name, math.random(1, 2))
      room:notifySkillInvoked(player, self.name, "defensive")
      room:changeMaxHp(player, 1)
    end
  end,
}

local ik__lianxi = fk.CreateTriggerSkill {
  name = "ik__lianxi",
  frequency = Skill.Compulsory,
  anim_type = "drawcard",
  events = { fk.MaxHpChanged },
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, self.name, "defensive")
    player:drawCards(2, self.name)
  end,
}

-- chaofen
local ik__chaofen = fk.CreateActiveSkill {
  name = "ik__chaofen",
  -- frequency = Skill.Compulsory,
  anim_type = "drawcard",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = room:getPlayerById(effect.from)
    -- local room = player.room
    -- 其他角色范围
    local other = room:getOtherPlayers(player)
    local to = room:askForChoosePlayers(player, table.map(other, Util.IdMapper), 1, 1, '#n_chaofen',
      self.name, false)[1]
    local tgt = room:getPlayerById(to)

    player:broadcastSkillInvoke(self.name, 3)
    room:notifySkillInvoked(player, 'ik__chaofen', 'control')

    local skills = Fk.generals[tgt.general]:getSkillNameList()
    if Fk.generals[tgt.deputyGeneral]  then
      table.insertTableIfNeed(skills, Fk.generals[tgt.deputyGeneral]:getSkillNameList())
    end
    skills = table.filter(skills, function(skill_name)
      local skill = Fk.skills[skill_name]
      return not player:hasSkill(skill, true) and
      (#skill.attachedKingdom == 0 or table.contains(skill.attachedKingdom, player.kingdom))
    end)
    if #skills > 0 then
      room:setPlayerMark(player, 'ik__chaofen', 1)
      local c = room:askForChoice(player, skills, self.name, "#ik__chaofen-choice::" .. tgt.id, true)
      room:handleAddLoseSkills(player, c, nil, true, true)
      room:changeMaxHp(player, -1)
      room:changeMaxHp(tgt, 1)

    end
  end,
}



local caixukun = General:new(extension, "ik__caixukun", "n_pigeon", 3)

caixukun:addSkill(ik__heihong)
caixukun:addSkill(ik__lianxi)
caixukun:addSkill(ik__chaofen)

Fk:loadTranslationTable {
  ["ik__caixukun"] = "蔡徐坤",
  ["#ik__caixukun"] = "个人练习生",
  ["designer:ik__caixukun"] = "一生明阳",
  ["cv:ik__caixukun"] = "蔡徐坤",
  ["illustrator:ik__caixukun"] = "视频截图",
  ["ik__heihong"] = "黑红",
  [":ik__heihong"] = "锁定技，当你受到伤害时，增加一点体力上限。",
  ["ik__lianxi"] = "练习",
  [":ik__lianxi"] = "锁定技，当你的体力上限发生变化时摸两张牌。",
  ["ik__chaofen"] = "炒粉",
  [":ik__chaofen"] = "出牌阶段限一次，你可以失去一点体力上限选择一名角色，使其增加一点体力上限，并获得他的一个技能。",
  ['#ik__chaofen'] = '炒粉: 失去一点体力上限，选择一名角色，使其增加一点体力上限，并获得他的一个技能。',
  ['#ik__chaofen-choice'] = '炒粉: 获得 %dest 的一个技能',
  ["$ik__heihong1"] = "只因你太美~",
  ["$ik__heihong2"] = "第一次压扁成这样的我",
  ["$ik__lianxi1"] = "全民制作人们大家好",
  ["$ik__lianxi2"] = "我是练习时长两年半的个人练习生，蔡徐坤",
  ["$ik__lianxi3"] = "喜欢唱、跳、篮球、rap,music",
  ["$ik__chaofen1"] = "所以你现在想知道男人跟男孩的区别对吧？",
  ["$ik__chaofen2"] = "一个真正的man",
  ["~ik__caixukun"] = "你干嘛，唉哟！",
}

return extension